package com.yubest.springboothello.service.impl;

import com.yubest.springboothello.interceptors.MdcInterceptor;
import com.yubest.springboothello.service.AsyncService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @Author: hweiyu
 * @Date: 2024/8/1 10:07
 */
@Service
@Slf4j
public class AsyncServiceImpl implements AsyncService {

    @Async
    @Override
    public void exec() {
        String traceId = MDC.get(MdcInterceptor.TRACE_ID);
        log.info("执行异步任务，tradeId: {}", traceId);
    }
}
